#include <iostream>
#include <conio.h>
using namespace std;

#define GREEN 0
#define RED 1
#define BLACK 2

class Roulette{
    public:

    Roulette(){
        srand((unsigned)time(NULL));
    }

    int roll(){
        int rndNr = rand()%37;
        if(rndNr==0) return GREEN;
        if(rndNr>0 && rndNr<19) return RED;
        return BLACK;
    }
};

class Player{
    public:
    int markers, played, won, currentBet;

    Player(int startAmount){
        markers = startAmount;
        played = won = 0;
        currentBet = 1;
    }
};

int main(void){
    Roulette wheel;
    string color[] = {"green", "red", "black"};
    bool done;

    cout << "Start amount  Survives    Average profit    Hourly wage" << endl;
    cout << "-------------------------------------------------------" << endl;

    for(int i=2000; i<9001; i+=1000){
        int won = 0, money = 0;
        for(int j=0; j<1000; j++){
            Player player(i);
            done = false;
            do{
                player.played++;
                if(wheel.roll() == RED){
                    player.won++;
                    player.markers += player.currentBet;
                    player.currentBet = 1;
                } else {
                    player.markers -= player.currentBet;
                    player.currentBet *= 2;
                }
                if(player.played == 10000) done = true;
                if(player.markers <= 0) done = true;
            } while (!done);
            if(player.played > 9999){
                won++; money += player.markers;}
            else
                money -= i;
        }
        cout << "" << i << "          " << (float) won/10 << "%        "
        << (float) money/1000 << "         " << ((float) money/1000)/250 << endl << endl;
    }

    return 0;
}
